﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace YandexWebmaster
{
    public partial class API
    {
        public User GetUserAPI(Account account) {
            // адрес сервера
            var serverAddress = "https://api.webmaster.yandex.net/v4/user";
            // устанавливаем заголовок
            httpClient.DefaultRequestHeaders.Add("Authorization", "OAuth " + account.OauthToken);
            var response = httpClient.GetAsync(serverAddress);
            User user = JsonConvert.DeserializeObject<User>(response.Result.Content.ReadAsStringAsync().Result);
            user.ID_account = account.ID;
            response.Dispose();
            return user;
        }
    }
}
